<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateResources extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('resources', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger("businessId")->default(0)->comment("模块子业务id");
            $table->string("module", 72)->default("")->comment("所属模块");
            $table->string("business", 72)->default("")->comment("模块子业务");
            $table->string("name", 120)->default("")->comment("名称");
            $table->string("url", 255)->default("")->comment("资源地址");
            $table->unsignedTinyInteger("isPublic")->default(0)->comment("是否公有资源");
            $table->integer("sort")->default(0)->comment("资源排序");
            $table->string("extra", 120)->default("")->comment("附加信息");

            $table->unsignedInteger('isDeleted')->default(0)->comment('是否删除 0 - 正常 1 - 已删除');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->index(["module", "business", "businessId"], 'idx_moduleBusinessId');
            $table->comment = '资源表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('resources');
    }
}
